package ${serviceImplPackageName};

import ${clientPackageName}.${domain.className}ServiceClient;
import ${domianPackageName}.${domain.className};
import ${servicePackageName}.${domain.className}Service;
import com.platform.common.domain.result.ParameterDataStruct;
import com.platform.common.domain.to.PageTo;
import com.platform.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* ${(domain.comment)!} service接口实现
*
* @author: ${domain.author}
* @version: 1.0
* @datetime: ${domain.datetime}
*/
@Service
@Slf4j
public class ${domain.className}ServiceImpl implements ${domain.className}Service {

    @Resource
    private ${domain.className}ServiceClient ${domain.lowerStartClassName}ServiceClient;

    @Override
    public void save(${domain.className} ${domain.lowerStartClassName}) throws Exception {
        ${domain.lowerStartClassName}ServiceClient.save(${domain.lowerStartClassName});
    }

    @Override
    public void modify(${domain.className} ${domain.lowerStartClassName}) throws Exception {
        ${domain.lowerStartClassName}ServiceClient.modify(${domain.lowerStartClassName});
    }

    @Override
    public void resort(${domain.className} ${domain.lowerStartClassName}) throws Exception {
        ${domain.lowerStartClassName}ServiceClient.resort(${domain.lowerStartClassName});
    }

    @Override
    public ${domain.className} findById(String ${domain.lowerStartClassName}Id) throws Exception {
        ${domain.className} ${domain.lowerStartClassName} = new ${domain.className}();
    <#list domain.keys as item>
        ${domain.lowerStartClassName}.set${item.upperStartName}(${domain.lowerStartClassName}Id);
    </#list>
        return ${domain.lowerStartClassName}ServiceClient.findById(${domain.lowerStartClassName});
    }

    @Override
    public List<${domain.className}> find(${domain.className} ${domain.lowerStartClassName}) throws Exception {
        return ${domain.lowerStartClassName}ServiceClient.find(${domain.lowerStartClassName});
    }

    @Override
    public PageInfo<${domain.className}> findPage(${domain.className} ${domain.lowerStartClassName}, PageTo page) throws Exception {
        ParameterDataStruct<${domain.className}> parameterDataStruct = new ParameterDataStruct<>();
        parameterDataStruct.setData(${domain.lowerStartClassName});
        parameterDataStruct.setPageTo(page);
        return ${domain.lowerStartClassName}ServiceClient.findPage(parameterDataStruct);
    }

    @Override
    public void remove(${domain.className} ${domain.lowerStartClassName}) throws Exception {
        ${domain.lowerStartClassName}ServiceClient.remove(${domain.lowerStartClassName});
    }
}

